package grape.house.rest.estatelicence.mvc;

import grape.house.rest.building.mapper.BuildingWebMapper;
import grape.house.rest.building.vo.BuildingPresalePermitVo;
import grape.house.rest.estatelicence.vo.EstateLicenceVo;
import grape.house.service.building.api.IBuildingService;
import grape.house.service.building.po.Building;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by yangwei
 * Created at 2020/9/30 9:33
 */

@Component
public class TransBuildingPresalePermitVoHelper {
    @Autowired
    private IBuildingService iBuildingService;
    @Autowired
    private BuildingWebMapper buildingWebMapper;

    public EstateLicenceVo transVo(EstateLicenceVo estateLicenceVo) {
        List<Building> byEstateIdAndpresaleEstateLicenceId = iBuildingService.getByEstateIdAndpresaleEstateLicenceId(estateLicenceVo.getEstateId(), estateLicenceVo.getId());
        List<BuildingPresalePermitVo> buildingVos = buildingWebMapper.posToBuildingPresalePermitVos(byEstateIdAndpresaleEstateLicenceId);
        estateLicenceVo.setPresalePermitBuildings(buildingVos);
        return estateLicenceVo;
    }
}
